<?php
  
 /**
  * @package JooS
  * @subpackage Syntax_PHPackager
  */

  require_once "JooS/Syntax/Complex/Transition.php";

  abstract class JooS_Syntax_PHPackager_Relations_Abstract extends JooS_Syntax_Complex_Transition {
    /**
     * @return JooS_Syntax_Abstract
     */
    abstract function getRelationItemSyntax();

    /**
     * @return string
     */
    public function compile() {
      $ret = parent::compile();
      if ($ret !== false) {
        return "array(" . $ret . ")";
      }
      return $ret;
    }

    /**
     * @return JooS_Syntax_Complex_Concatenate
     */
    protected function createRule() {
      return $this->createSyntax("Complex_Concatenate", array(
        $this->createSyntax("Common_Whitespace"), 

        $this->createSyntax("Complex_Repetition", $this->createSyntax("Complex_Concatenate", array(
          $this->getRelationItemSyntax(), 
          $this->createSyntax("Complex_Repetition", $this->createSyntax("Complex_Concatenate", array(
            $this->createSyntax("Common_Whitespace"), 
            $this->createSyntax("Simple_Symbol", ","), 
            $this->createSyntax("Common_Whitespace"), 
            $this->getRelationItemSyntax(), 
          ))), 
          $this->createSyntax("Common_Whitespace"), 
        )), 1), 
      ));
    }
  }
